<?php
/*
 * This file is part of tOAuth Class
 * Copyright (C) 2009-2010, Sergio Cruz aka scromega (scr.omega at gmail dot com)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

//session_start();

//include '../consultas.php';

//$twetter = tweeter($conexion); 
	//$arr2 = mysql_fetch_array($twetter);
	//$_SESSION['toauth_ats'] = $arr2[0];
	//$_SESSION['toauth_at'] = $arr2[1];
require('modelo_twitter.php');
include '../connections/conn.php';
?>

<div id="twitter" style="margin-top:5px;">

<?php
$r1=mostrar_menciones();
//echo '<pre>'.print_r($r1, true).'</pre>';
for($a=0;$a<count($r1);$a++)
{
	?>
    <div id="cc" style="width:50%;">
    <table width="100%">
    <tr><td rowspan="3" style="background:#E1F0FC;" width="40px"><img src="<?php echo $r1[$a]['user']['profile_image_url']; ?>" border="0" width="40px" height="40px"></td>
	<td style="background:#E1F0FC;"><?php echo $r1[$a]['user']['name'];?></td></tr>
    <tr><td style="background:#E1F0FC;"><?php echo $r1[$a]['text'];?></td></tr>
    <tr><td style="background:#E1F0FC;"><?php echo $r1[$a]['created_at'];?></td></tr>
    <?php $query2="SELECT id_usuarios,Departamento_id_departamento as depto,twitter FROM usuarios WHERE twitter='".$r1[$a]['user']['screen_name']."'";
	$consulta2=mysql_query($query2,$conexion);
			if(mysql_num_rows($consulta2)>0)
			{
				$row2=mysql_fetch_array($consulta2);
				?>
				<script>ventanita('../ticket/ver_cate1.php?usuario=<?php echo $row2['id_usuarios']?>&depto=<?php echo $row2['depto']?>&descrip=<?php echo $r1[$a]['text']?>','Seleccionar Asunto');</script>
				<?php
			}
			else
			{?>
<tr><td style="background:#E1F0FC;"><a href="javascript:popup2('../twitter/enviar_post.php?us=<?php echo $r1[$a]['user']['screen_name'];?>');" >Replay</a> </td></tr>
	  <?php } ?> 	
    </table>
<div id="respuesta_<?php echo $a; ?>" style="width:100%">
</div>
</div>
<?php //$r2 = $connection->post('statuses/update', array('status'=>'@'.$r1[$a]['user']['screen_name'].' '.'probando replay'));
 }
?>
</div>